package cn.tedu.yl.recharge.controller;

import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.recharge.pojo.dto.RechargeQuery;
import cn.tedu.yl.recharge.pojo.dto.RechargeSaveParam;
import cn.tedu.yl.recharge.pojo.vo.RechargeVO;
import cn.tedu.yl.recharge.service.RechargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/recharge")
public class RechargeController {
    @Autowired
    private RechargeService rechargeService;

    @PostMapping("save")
    public JsonResult save(RechargeSaveParam rechargeSaveParam){
        rechargeService.save(rechargeSaveParam);
        return JsonResult.ok("操作成功");
    }

    @GetMapping("select")
    public JsonResult select(RechargeQuery rechargeQuery){
        List<RechargeVO>  list = rechargeService.select(rechargeQuery);
        return JsonResult.ok(list);
    }
}
